-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "Procstat: don't cache PIDs" #2479
Conversation
cc @jarondl Unfortunately I need to revert your PR. I have just realized that this results in the cpu_usage of the process not working, since this relies on caching the previous values of CPU times. Please feel free to resubmit your PR if you can find a solution around this. |
Yikes. So |
That's correct, and it's not possible for gopsutil to workaround this. Calculating CPU usage inherently requires two "cpu time" readings, which is why the first collection of CPU metrics never has any usage fields defined. |
Well the correct (but backwards incompatible) way to architecture this is to save cumulative cpu time itself. The other benefit of this scheme is that even if you miss a read you don't miss a cpu usage spike. |
Could be useful to have a cpu_time metric, but I think we will also want a simple to graph stat like the cpu_usage. We should be able to recreate processes only for pids that change, I doubt the pid would be reused so quickly as to not be detected. |
@jarondl CPU time -> % usage isn't quite that simple and is platform-specific, I think it would be a bit abnormal for a data collector that doesn't do the usage calculation itself. We do already provide the raw time metrics if you want them, but we |
Reverts #2206